<?php require_once(dirname(__FILE__)."/../config/config.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php  
if($_SESSION['admin_name']=="")
{

	echo "<script>location.href='admin_login.php';</script>";
}
?>
<?php
	switch($_GET["action"]){
	//添加管理员信息
	case "registration":     
	$admin_name=$_POST[admin_name];
	$admin_password=$_POST[admin_password];
	$remark=$_POST[remark];
	$page=$_REQUEST['page'];
	if($admin_name!="" && $admin_password!=""){
		$sql="INSERT INTO zy_admin (admin_name, admin_password, remark) VALUES('$admin_name','$admin_password','$remark')";
		mysql_query($sql);
	}
	$admin_id=mysql_insert_id($myconn);
	if($admin_id>0){
		header("location:admin_list.php?page=".$page);
	}else{ 
		echo "<h3>管理员信息发布失败!</h3>";}
		echo "<a href='admin_list.php'>浏览管理员信息</a>  ";
		echo "<a href='admin_registration.php'>返回</a>&nbsp;&nbsp;";
	break;
	//删除管理员信息
	case  "del":
	$page=$_REQUEST['page'];
	$admin_id = $_GET['admin_id'];
	$sql = "delete from zy_admin where admin_id = '".$admin_id."'";
	mysql_query($sql);
	header("location:admin_list.php?page=".$page);
	break;
	//修改管理员信息
	case "update":
	$admin_name = $_POST["admin_name"];
	$admin_password = $_POST["admin_password"];
	$remark = $_POST["remark"];
	$admin_id=$_GET['admin_id'];
	$page=$_REQUEST['page'];
	if($admin_name!="" && $admin_password!=""){
	$sql = "update zy_admin set admin_name='".$admin_name."', admin_password='".$admin_password."',remark = '".$remark."' where admin_id ='".$admin_id."'";
	mysql_query($sql);
	header("location:admin_list.php?page=".$page);
	}else{
		echo "<h3>管理员信修改失败!</h3>";?>
		<a href="admin_list.php">浏览管理员信息</a>&nbsp;&nbsp;
		<a href="admin_edit.php?admin_id=<?php echo $admin_id;?>">返回</a>
	<?php }
	break;
}
?>
</body>
</html>